package com.woniuxy.enjoylife.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class OrderNumberCreator {


    //创建商品订单编号
    public static String createGoodsOrderNum() {
        String str = "ELGO";
        return getOrderString(str);
    }

    //创建服务订单编号
    public static String createServerOrderNum() {
        String str = "ELSO";
        return getOrderString(str);
    }

    //生成编号
    private static String getOrderString(String str) {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmSSSS");
        str += sdf.format(date);
        //生成随机数
        String random = new Random().nextInt(10000) + "";
        for (int i = 4; i > random.length(); i--) {
            str += "0";
        }
        str += random;
        return str;
    }


}
